home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / BSP Tree 1.2 / Sources / Graphics / include / iterator_3d.h < prev    next >
Encoding:
Text File  |  1995-03-26  |  2.0 KB  |  48 lines  |  [TEXT/MMCC]

  1. //------------------------------------------------------------------------------
  2. //    File:                    iterator.h
  3. //    Date:                    9/26/94
  4. //    Author:                Bretton Wade
  5. //
  6. //    Description:    this file contains the class definition for a list iterator
  7. //
  8. //------------------------------------------------------------------------------
  9.  
  10. #include "listptr_3d.h"
  11.  
  12. #ifndef    ITERATOR
  13. #define    ITERATOR
  14.  
  15. //------------------------------------------------------------------------------
  16. //    classes
  17. //------------------------------------------------------------------------------
  18. class    iterator                                                                                                                                    //    polygon list iterator class
  19. {                                                                                                                                                                //    begin class definition
  20.     private:                                                                                                                                            //    members internal to this class only
  21.     protected:                                                                                                                                        //    members internal to this class hierarchy
  22.                 listptr    list;                                                                                                                        //    pointer to the list in use
  23.                 polylist::node    *current;                                                                                                //    pointer to the node the iterator is examining
  24.     public:                                                                                                                                                //    members available externally
  25.                 iterator (const listptr &list);                                                                                    //    normal constructor
  26.                 ~iterator (void);                                                                                                                //    destructor
  27.                 polyptr    operator () (void);                                                                                            //    function call operator
  28.                 void        Reset (void);                                                                                                        //    start at the head of the list
  29. };                                                                                                                                                            //    end polygon class definition
  30.  
  31. //------------------------------------------------------------------------------
  32. //    inlines
  33. //------------------------------------------------------------------------------
  34. inline    polyptr    iterator::operator () (void)                                                                        //    function call operator
  35. {                                                                                                                                                                //    begin
  36.     if (current)
  37.     {
  38.         polylist::node    *hold = current;
  39.         current = current->next;
  40.         return hold->ptr;
  41.     }
  42.     else
  43.         return polyptr ();
  44. }                                                                                                                                                                //    end
  45.  
  46. //------------------------------------------------------------------------------
  47.  
  48. #endif    //ITERATOR